# -*- coding: utf-8 -*-

"""
 (c) 2023 - Copyright CTyunOS Inc

 Authors:
   youyifeng <youyf2@chinatelecom.cn>

"""

from .base import DBModel
from sqlalchemy import Column
from sqlalchemy import Text
from sqlalchemy import Integer
from sqlalchemy import String
from sqlalchemy import JSON


class NVD(DBModel):
    __tablename__ = 'NVD'
    id = Column('id', Integer, primary_key=True)

    cve_id = Column('cve_id', String(length=20))
    description = Column('description', Text)

    # cvss2 = Column(JSON, nullable=True)
    # cvss2_level = Column(String(length=10), nullable=True)
    # cvss2_score = Column(Float, nullable=True)
    #
    # cvss3 = Column(JSON, nullable=True)
    # cvss3_score = Column(Float, nullable=True)
    # cvss3_level = Column(String(length=10), nullable=True)

    cve = Column('cve', JSON)
    configurations = Column('configurations', JSON)
    impact = Column('impact', JSON)
    publishedDate = Column('publishedDate', String(length=20))
    lastModifiedDate = Column('lastModifiedDate', String(length=20))

    COLUMN = [
        "id",
        "cve_id",
        "description",
        "cve",
        "configurations",
        "impact",
        "publishedDate",
        "lastModifiedDate",
    ]

    def pretty_output(self):
        print("%-30s %-30s" % (
            self.cve_id,
            self.publishedDate,
        ))

    def format_output(self):
        print("%-30s %-30s" % (
            self.cve_id,
            self.publishedDate,
        ))
